
package rgb.power.led.controller;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Twistx77
 */
public class Configuration implements Serializable{
    
    private static final long serialVersionUID = 278769785;
    
    String[] color1 = {"ALFA DELTA", "14", "13", "0", "0", "0", "0"};
    String[] color2 = {"ALFA THETA", "0", "0", "0", "0", "0", "0"};
    String[] color3 = {"ALFA", "0", "0", "0", "0", "0", "0"};
    String[] color4 = {"DELTA", "0", "0", "0", "0", "0", "0"};
    String[] color5 = {"THETA", "0", "0", "0", "0", "0", "0"};
    String[] color6 = {"MU THETA", "0", "0", "0", "0", "0", "0"};
    String[] color7 = {"MU DELTA", "0", "0", "0", "0", "0", "0"};
    String[] color8 = {"MU μ", "0", "0", "0", "0", "0", "0"};
    String[] color9 = {"MU UPSILON μν", "0", "0", "0", "0", "0", "0"};
    String[] color10 = {"MU PI μν", "0", "0", "0", "0", "0", "0"};    
    String[] color11 = {"PI π", "0", "0", "0", "0", "0", "0"};
    String[] color12 = {"OMEGA ω", "0", "0", "0", "0", "0", "0"};
    String[] color13 = {"UPSILON ν", "0", "0", "0", "0", "0", "0"};
    String[] color14 = {"UPSILON ν", "0", "0", "0", "0", "0", "0"};
    String[] color15 = {"PIUPSILON πν", "0", "0", "0", "0", "0", "0"};
    String[] color16 = {"UPSILON OMEGA νω", "0", "0", "0", "0", "0", "0"};
    String[] color17 = {"ALFA OMEGA αω", "0", "0", "0", "0", "0", "0"};
    String[] color18 = {"LAMBDA λ", "0", "0", "0", "0", "0", "0"};
    String[] color19 = {"DEPRESOR D", "0", "0", "0", "0", "0", "0"};
    String[] color20 = {"ESTIMULANTE S", "0", "0", "0", "0", "0", "0"};
    String[] color21 = {"SPARE 1", "0", "0", "0", "0", "0", "0"};
    String[] color22 = {"SPARE 2", "0", "0", "0", "0", "0", "0"};
    String[] color23 = {"SPARE 3", "0", "0", "0", "0", "0", "0"};
    String[] color24 = {"SPARE 4", "0", "0", "0", "0", "0", "0"};
    String[] color25 = {"SPARE 5", "0", "0", "0", "0", "0", "0"};
    String[] color26 = {"SPARE 6", "0", "0", "0", "0", "0", "0"};
    String[] color27 = {"SPARE 7", "0", "0", "0", "0", "0", "0"};
    String[] color28 = {"SPARE 8", "0", "0", "0", "0", "0", "0"};
    
  
        int[] preset1 = {0,0,0,0,0,0};
        int[] preset2 = {0,0,0,0,0,0};
        int[] preset3 = {0,0,0,0,0,0};
        int[] preset4 = {0,0,0,0,0,0};
        int[] preset5 = {0,0,0,0,0,0};
        int[] preset6 = {0,0,0,0,0,0};
        int[] preset7 = {0,0,0,0,0,0};
        int[] preset8 = {0,0,0,0,0,0};
        int[] preset9 = {0,0,0,0,0,0};
        int[] preset10 = {0,0,0,0,0,0};
    
    
    ArrayList<int[]> presetsConfigList = new ArrayList (Arrays.asList(preset1, preset2, preset3,preset4,preset5,preset6,preset7,preset8,preset9,preset10));

     
    
    ArrayList<String[]> colorsConfigList = new ArrayList(Arrays.asList(color1, color2, color3, color4, color5, color6, color7, color8,
            color9, color10, color11, color12, color13,color14, color15, color16, color17, color18, color19,color20, color21, color22,
            color23, color24, color25, color26, color27, color28));
    



    public Configuration() {
   
    }

    public ArrayList<String[]> getColorsConfigList() {

        return colorsConfigList;

    }

    public void setColorsConfigList(ArrayList<String[]> list) {
        String[] stringTemp = new String[6];
        colorsConfigList = list;
        for (int i = 0; i < list.size(); i++) {
            stringTemp = list.get(i);

        }

    }

    public Configuration readConfig() throws IOException, ClassNotFoundException {
        Configuration config = null;

        File currentDir = new java.io.File("");
        File file = new java.io.File(currentDir.getAbsolutePath(), "config");
        if (file.exists()) {
            FileInputStream fis;
            try {
                fis = new FileInputStream("config");
                ObjectInputStream ois = new ObjectInputStream(fis);
                config = (Configuration) ois.readObject();
                fis.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);

            }
         
            return (config);
        } else {
            saveConfig();
            return (new Configuration());
        }


    }

    
    public void saveConfig() throws IOException {
        try (FileOutputStream fos = new FileOutputStream("config")) {
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            String[] temp = new String[6];
            oos.writeObject(this);
        }
    }
}
